---
title: 
- Replication package for "Incentivizing Peace"
author: 
- Johannes Karreth
date: 
- February 15, 2018

output:
  rmdformats::readthedown:
    highlight: default
---

# Overview

This folder contains all data and code to reproduce the analyses in: 

> Tir, Jaroslav and Johannes Karreth. 2018. *Incentivizing Peace: How International Organizations Can Help Prevent Civil Wars in Member Countries*. New York: Oxford University Press. ISBN: 9780190699529.

All contents of this folder are posted at <https://dataverse.harvard.edu/dataverse/jkarreth>, and more information on the book is available at <http://www.jkarreth.net/incentivizing-peace.html>. For any questions, please contact the authors at <jkarreth@ursinus.edu>.

All datasets needed to perform the analyses are provided in the `Source` folder.

All tables and figures produced by these scripts are written to the `Output_Tables` and `Output_Figures` folder. 

The `Functions` folder contains custom R functions used in this project. Where applicable, credits for code obtained from other researchers are noted at the beginning of each function.

All analyses using R were executed on R version 3.4.1 (2017-06-30) on OS X El Capitan 10.11.6; a list of packages and versions used is at the end of this file. Analyses using Stata were executed on Stata/SE 13.1 for Mac (64-bit Intel), Revision 16 Dec 2016.

# Data sources

All data sources are documented in the book's *Data Appendix*. The files below contain all the data necessary to reproduce the analyses in the book:

- `esc.xlsx`: List of all conflicts analyzed in the book, with authors' coding of escalation to civil war
- `Escalation.xls`: List of all conflicts that escalated to civil war
- `hsigo_count.csv`: Membership count in highly structured IGOs for each country in 1950, 1975, and 2000 (for Figure 3.5)
- `IGO_igounit_v2.3.csv`: COW IGO data, IGO level
- `igo.cw.replication_allvars_fewermissing_forstata.dta`: Data for instrumental variable analysis, with some missing data filled in from alternative sources (Stata version)
- `igo.cw.replication_allvars_fewermissing.csv`: Data for instrumental variable analysis, with some missing data filled in from alternative sources
- `igo.fiveades.csv`: Membership count in highly structured IGOs for each country in each year since 1946, with counts interpolated by 5-year periods until 1965
- `IGOCW_escalation-analyses.csv`: Data for analyses in Chapters 4 and 5
- `IGOCW_escalation-selection-analyses.csv`: Data for Heckman probit estimates in Chapter 4
- `IGOCW_escalation-selection-analyses.dta`: Data for Heckman probit estimates in Chapter 4, Stata format
- `ivhsigo.csv`: Instrumented estimates of HSIGO memberships, produced by `chapter5.R`, necessary to create Figure 5.9
- `ivpmargins.xlsx`: IV probit coefficient estimates, produced by `chapter5.R`, necessary to Table 5.5
- `TM_WORLD_BORDERS_SIMPL-0.3`: Shape file for world map provided by Bjorn Sandvik, thematicmapping.org

# Instructions

To reproduce the analyses in each chapter, execute the script associated with the respective chapter. Note that the working directory should be set to the folder "Replication", which contains the elements of this replication package.

## Chapter 3

The script `chapter3.R` produces the following files:

- `ch3_figX_igo-count-year.pdf` (Figure 3.1)
- `ch3_figX_igo-size-recent.pdf` (Figure 3.2)
- `ch3_figX_igo-individual-year.pdf` (Figure 3.3)
- `ch3_figX_igo-sumstats-year.pdf` (Figure 3.4)
- `ch3_figX_hsigo-gridmap.pdf` (Figure 3.5)
- `ch3_figX_hsigo-map1950.pdf` (part of Figure 3.5)
- `ch3_figX_hsigo-map1975.pdf` (part of Figure 3.5)
- `ch3_figX_hsigo-map2000.pdf` (part of Figure 3.5)
- `ch3_figX_hsigo-map2000-escalations.pdf` (not in the book)
- `ch3_figX_igo-size.pdf` (not in the book)

## Chapter 4

The script `chapter4.R` produces the following files:


- `ch4_figX_conflictmap.pdf` (Figure 4.1)
- `ch4_figX_escalationmap.pdf` (Figure 4.2)
- `ch4_figX_m1-pp.pdf` (Figure 4.3)
- `ch4_figX_m1-fd.pdf` (Figure 4.4)
- `ch4_figX_polity-pp.pdf` (Figure 4.5)
- `ch4_figX_m1-selection-fd.pdf` (Figure 4.6)
- `ch4_figX_conflict-escalationmap.pdf` (not in the book)
- `ch4_figX_m1-out-fd.pdf` (not in the book)
- `ch4_figX_m1-sel-fd.pdf` (not in the book)
- `ch4_tabX_descstats.tex` (Table 4.2)
- `ch4_tabX_escalation-m1.tex` (Table 4.3)

## Chapter 5

The script `chapter5.R` produces the files below. Note that the IV probit regression was estimated using Stata. The R script contains the relevant Stata code in Section 1 ("IV probit")

- `ch5_figX_escalation-cb-fd.pdf` (Figure 5.1)
- `ch5_figX_escalation-cb-pp.pdf` (Figure 5.2)
- `ch5_figX_settle-fd.pdf` (Figure 5.3)
- `ch5_figX_settle-pp.pdf` (Figure 5.4)
- `ch5_figX_mi-tab.pdf` (Figure 5.5)
- `ch5_figX_escalation-mi-fd.pdf` (Figure 5.6)
- `ch5_figX_escalation-mi-pp.pdf` (Figure 5.7)
- `ch5_figX_escalation-desc.pdf` (Figure 5.8)
- `ch5_figX_escalation-iv-pp.pdf` (Figure 5.9)
- `ch5_figX_escalation-resources-pp.pdf` (Figure 5.10)
- `ch5_figX_escalation-rebstrength-pp.pdf` (Figure 5.11)
- `ch5_figX_escalation-timespace-fd.pdf` (Figure 5.12)
- `ch5_figX_escalation-neighbors-fd.pdf` (Figure 5.13)
- `ch5_figX_escalation-bma2.pdf` (Figure 5.14)
- `ch5_figX_escalation-bma1.pdf` (Figure 5.15)
- `ch5_figX_escalation-instiv-pp.pdf` (not in the book)
- `ch5_figX_escalation-iv-obs.pdf` (not in the book)
- `ch5_tabX_escalation-m1cb-full.tex` (Table 5.2)
- `ch5_tabX_settle-m2.tex` (Table 5.3)
- `ch5_tabX_escalation-mi.tex` (Table 5.4)
- `ch5_tabX_escalation-iv.tex` (Table 5.5)
- `ch5_tabX_escalation-resources.tex` (Table 5.6)
- `ch5_tabX_escalation-resources_int.tex` (Table 5.7)
- `ch5_tabX_escalation-rebstrength.tex` (Table 5.8)
- `ch5_tabX_escalation-timespace.tex` (Table 5.9)
- `ch5_tabX_escalation-neighbors.tex` (Table 5.10)
- `ch5_tabX_escalation-territory.tex` (Table 5.11)
- `ch5_tabX_escalation-m1cb.tex` (not in the book)

# Software information

The `sessionInfo()` output below shows the versions of all R packages used in the analyses in the book.

```
R version 3.4.1 (2017-06-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets 
[7] methods   base     

other attached packages:
 [1] BMA_3.18.7            rrcov_1.4-3          
 [3] inline_0.3.14         robustbase_0.92-7    
 [5] leaps_3.0             multcomp_1.4-6       
 [7] TH.data_1.0-8         survival_2.41-3      
 [9] mvtnorm_1.0-6         sampleSelection_1.0-4
[11] maxLik_1.3-4          miscTools_0.6-22     
[13] pastecs_1.3-18        boot_1.3-19          
[15] reshape2_1.4.2        plotly_4.7.1         
[17] MASS_7.3-47           effects_3.1-2        
[19] texreg_1.36.23        xtable_1.8-2         
[21] gridExtra_2.2.1       RColorBrewer_1.1-2   
[23] rgdal_1.2-8           foreign_0.8-69       
[25] countrycode_0.19      maps_3.2.0           
[27] maptools_0.9-2        sp_1.2-5             
[29] ggplot2_2.2.1         bindrcpp_0.2         
[31] dplyr_0.7.2          

loaded via a namespace (and not attached):
 [1] nlme_3.1-131       pbkrtest_0.4-7     lubridate_1.6.0   
 [4] devtools_1.13.2    httr_1.2.1         R.cache_0.12.0    
 [7] tools_3.4.1        R6_2.2.2           lazyeval_0.2.0    
[10] mgcv_1.8-17        colorspace_1.3-2   nnet_7.3-12       
[13] systemfit_1.1-20   withr_1.0.2        repmis_0.5        
[16] curl_2.8.1         compiler_3.4.1     quantreg_5.33     
[19] SparseM_1.77       sandwich_2.4-0     labeling_0.3      
[22] scales_0.4.1       DEoptimR_1.0-8     lmtest_0.9-35     
[25] stringr_1.2.0      digest_0.6.12      minqa_1.2.4       
[28] R.utils_2.5.0      rio_0.5.5          pkgconfig_2.0.1   
[31] htmltools_0.3.6    lme4_1.1-13        htmlwidgets_0.9   
[34] rlang_0.1.1        readxl_1.0.0       rstudioapi_0.6    
[37] VGAM_1.0-4         shiny_1.0.3        bindr_0.1         
[40] zoo_1.8-0          jsonlite_1.5       crosstalk_1.0.0   
[43] R.oo_1.21.0        car_2.1-5          magrittr_1.5      
[46] Formula_1.2-2      Matrix_1.2-10      Rcpp_0.12.12      
[49] munsell_0.4.3      R.methodsS3_1.7.1  stringi_1.1.5     
[52] yaml_2.1.14        plyr_1.8.4         parallel_3.4.1    
[55] forcats_0.2.0      lattice_0.20-35    gpclib_1.5-5      
[58] haven_1.1.0        splines_3.4.1      codetools_0.2-15  
[61] stats4_3.4.1       glue_1.1.1         data.table_1.10.4 
[64] nloptr_1.0.4       httpuv_1.3.5       MatrixModels_0.4-1
[67] cellranger_1.1.0   gtable_0.2.0       purrr_0.2.2.2     
[70] tidyr_0.6.3        reshape_0.8.6      assertthat_0.2.0  
[73] openxlsx_4.0.17    mime_0.5           pcaPP_1.9-72      
[76] viridisLite_0.2.0  tibble_1.3.3       memoise_1.1.0     
[79] cluster_2.0.6   
```
